<template>
  <ul id="category-menu">
    <li
      class="menu-item"
      v-for="(item, index) in menuList"
      :key="item.maitKey"
      @click="menuClick(index, item.maitKey, item.miniWallkey)"
      :class="{ active: currentIndex === index }"
    >
      {{ item.title }}
    </li>
  </ul>
</template>
<script>
export default {
  name: "CategoryMenu",
  props: {
    menuList: {
      type: Array,
      default: () => [],
    },
  },
  data() {
    return {
      currentIndex: 0,
    };
  },
  methods: {
    menuClick(index, maitKey, miniWallkey) {
      this.currentIndex = index;
      this.$emit("menuClick", maitKey, miniWallkey);
    },
  },
};
</script>
<style scoped>
#category-menu {
  width: 100px;
  height: 100%;
  background-color: #f6f6f6;
}
.menu-item {
  height: 45px;
  text-align: center;
  line-height: 45px;
  font-size: 14px;
}
.active {
  background-color: #fff;
  color: #ff5777;
  font-weight: 700;
  border-left: solid 3px #ff5777;
}
</style>
